<?php
            include 'connectdb.php';
            $q = "select * from home_stay where home_stay_id =".$_REQUEST['home_stay_name'];
            $result = mysqli_query($link, $q);
            $row = mysqli_fetch_array($result);
 ?>
<script type="text/javascript">
$(function() {
        $('#gallery a').lightBox();
    });
    
$(function() {
        $('#gallery2 a').lightBox();
    });    
</script>
<table width="764" border="1">
    <tr>
        <td><strong><font size="4"><?php echo $row['home_stay_name'];?></font></strong></td>
    </tr>
    <tr>
        <td>ที่อยู่&nbsp;:<br/><?php echo $row['home_stay_location'];?></td>
    </tr>
    <tr>
        <td>รายละเอียด&nbsp;:<br/><?php echo nl2br($row['home_stay_detail']);?></td>
    </tr>
    <tr>
        <td>
        <div id="gallery">    
        รูปภาพ&nbsp;:<br/>
        <?php
            $q2 = "select * from picture where home_stay_id =".$_REQUEST['home_stay_name'];
            $result2 = mysqli_query($link, $q2);
            if (mysqli_num_rows($result2)== 0){
                echo '<a href="images/no_image/no_image.jpeg"><img src="images/no_image/no_image.jpeg" width=72 height=72 alt=""/></a>&nbsp;';    
            }
            else{
                    while ($row2 = mysqli_fetch_array($result2)){
                        echo '<a href='.$row2["picture_address"].'><img src='.$row2["picture_address"].' width=72 height=72 alt=""/></a>&nbsp;';
                }
            }
        ?>
        </div>
        </td>
    </tr>
    <tr>
        <td>
            <table width="764" border="1">
                    <tr>
                        <td width="100" align="center">ชื่อห้อง</td>
                        <td align="center">รายละเอียด</td>
                        <td width="100" align="center">จำนวน(คน)</td>
                    </tr>
                    <?php
                    $q3 = "select * from home_stay_room where home_stay_id =".$_REQUEST['home_stay_name'];
                    $result3 = mysqli_query($link, $q3);
                    while ($row3 = mysqli_fetch_array($result3)){
                    ?>
                        <tr>                         
                            <td valign="top">
                                <div id="gallery2">
                                <?php echo $row3['home_stay_room_name']; 
                                echo '<br/>';
                                
                                    if($row3['home_stay_room_picture'] == ''){
                                        echo '<img src="images/no_image/no_image.jpeg" width=72 height=72>';
                                    }
                                    else{
                                        echo "<img src=".$row3['home_stay_room_picture']." width=72 height=72>";
                                    }
                                ?>
                            </div>    
                            </td>
                            <td valign="top"><br/><?php echo nl2br($row3['home_stay_room_detail']);?></td>
                            <td align="center"><?php echo $row3['max'];?></td>
                        </tr>
                    <?php    
                    }    
                    ?>
            </table>
        </td>
    </tr>
    <tr>
        <td align="center">ตรวจสอบห้องว่างได้ที่ปุ่ม "ตรวจสอบ" ค่ะ</td>
    </tr>
</table>